package o;

import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import com.huawei.appgallery.foundation.ui.framework.widget.dialog.dialogactivity.DialogActivity;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.List;
import o.bob.c;
import o.bob.e;
import o.ckh.a;

public class bpl {
    private final String ˊ;
    private final bpj ˋ;
    private final OnCancelListener ˎ = new OnCancelListener(this) {
        final /* synthetic */ bpl ˎ;

        {
            this.ˎ = r1;
        }

        public void onCancel(DialogInterface dialogInterface) {
            this.ˎ.ˋ.ˊ(false, null);
        }
    };
    private final a ˏ = new a(this) {
        final /* synthetic */ bpl ˎ;

        {
            this.ˎ = r1;
        }

        public void ˏ(AlertDialog alertDialog, DialogActivity.a aVar, int i) {
            if (-2 == i) {
                this.ˎ.ˋ.ˊ(false, null);
            }
            if (-1 == i) {
                this.ˎ.ˋ.ˊ(true, null);
            }
        }
    };
    private final Context ॱ;

    public bpl(@NonNull Context context, @NonNull String str, @NonNull bpj o_bpj) {
        this.ॱ = context;
        this.ˊ = str;
        this.ˋ = o_bpj;
    }

    @Nullable
    public PendingIntent ˎ(long j, @NonNull List<Integer> list, boolean z) {
        View ˊ;
        try {
            ˊ = ˊ(j, list, z);
        } catch (Throwable e) {
            boc.ˎ.ˊ("InstallConfirmActivity", "Exception when creating the view for InstallConfirmActivity, " + e, e);
            ˊ = null;
        }
        if (ˊ == null) {
            return null;
        }
        DialogActivity.a ˏ = new DialogActivity.a(this.ॱ, "FeatureInstallConfirm").ˎ(ˊ, null).ˏ(this.ˏ).ˋ(-2, e.ˊ).ˋ(-1, e.ˎ).ˏ(this.ˎ);
        CharSequence ˊ2 = bof.ˊ().ˊ();
        if (!TextUtils.isEmpty(ˊ2)) {
            ˏ.ˏ(ˊ2);
        }
        return ˏ.ॱ();
    }

    @Nullable
    View ˊ(long j, @NonNull List<Integer> list, boolean z) {
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        View inflate = from.inflate(bob.a.ˏ, null);
        LinearLayout linearLayout = (LinearLayout) inflate.findViewById(c.ˋ);
        ((TextView) inflate.findViewById(c.ˎ)).setText(this.ॱ.getResources().getString(e.ˏ, new Object[]{ˊ(), ˋ(j)}));
        for (Integer num : list) {
            View inflate2 = from.inflate(bob.a.ॱ, null);
            ((TextView) inflate2.findViewById(c.ˊ)).setText(ˎ(num.intValue()));
            linearLayout.addView(inflate2);
        }
        if (z) {
            View inflate3 = from.inflate(bob.a.ॱ, null);
            ((TextView) inflate3.findViewById(c.ˊ)).setText(e.ॱ);
            linearLayout.addView(inflate3);
        }
        return inflate;
    }

    @NonNull
    private String ˎ(@StringRes int i) {
        return bla.ˎ(this.ॱ, this.ˊ, i);
    }

    @NonNull
    private String ˊ() {
        return bla.ˎ(this.ॱ, this.ˊ);
    }

    static String ˋ(long j) {
        double d = ((double) j) / 1048576.0d;
        DecimalFormat decimalFormat;
        if (d >= 0.1d) {
            decimalFormat = new DecimalFormat("#.#");
            decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
            return decimalFormat.format(d);
        } else if (d < 0.01d) {
            return "0.01";
        } else {
            decimalFormat = new DecimalFormat("#.##");
            decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
            return decimalFormat.format(d);
        }
    }
}
